package indi.fritz.bigmap;

import java.io.File;
import java.io.IOException;

import indi.fritz.bigmap.common.Options;
import indi.fritz.bigmap.volme.DiskEngine;
import indi.fritz.bigmap.volme.Engine;

public class MapBuild {
	
	public static Build Build(String folder){
		Options options = new Options();
		options.setFolder(new File(folder));
		return new Build(options);
	}
	
	public static class Build{
		Options options;
		
		private Build(Options options){
			this.options = options;
		}
		
		public Build createIfNotExist(boolean flag) {
			this.options.setCreateIfNotExist(flag);
			return this;
		}
		
		public Build clearOnOpen(boolean flag) {
			this.options.setClearOnOpen(flag);
			return this;
		}
		
		public Build readonly(boolean flag) {
			this.options.setReadonly(flag);
			return this;
		}
		
		public Build exclusive(boolean flag) {
			this.options.setExclusive(flag);
			return this;
		}
		
		public Engine build() throws IOException {
			return new DiskEngine(this.options);
		}
	}
}
